<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
var successfulPairs = function(spells, potions, success) {
    const ans = [];
    potions.sort((a, b) => a - b);
    for (const sep of spells) {
        const target = success / sep;
        let left = 0, right = potions.length, mid;
        while (left < right) {
            mid = left + ((right - left) >> 1);
            if (potions[mid] < target) {
                left = mid + 1;
            } else {
                right = mid;
            }
        }
        ans.push(potions.length - left)        
    }
    return ans;
};
  </script>
</body>
</html>